package com.licheng.service.provider;

import com.licheng.dao.provider.ProviderMapper;
import com.licheng.entity.Provider;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service("providerService")
public class ProviderServiceImpl implements ProviderService {
    @Resource
    private ProviderMapper providerMapper;

    public ProviderMapper getProviderMapper() {
        return providerMapper;
    }

    public void setProviderMapper(ProviderMapper providerMapper) {
        this.providerMapper = providerMapper;
    }


    @Override
    public List<Provider> findProviderWithConditions() throws Exception {
        try {
            return providerMapper.Prolist();//调用DAO方法实现查询
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public List<Provider> findProFuzzyQuery(Provider provider) throws Exception {
        try {
            return providerMapper.ProFuzzyQuery(provider);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }

    }

    @Override
    public boolean addNewPro(Provider provider) throws Exception {
       boolean result=false;
       try {
           if(providerMapper.ProAdd(provider)==1){
               result=true;
           }
       }catch (Exception e){
           e.printStackTrace();
           throw e;
       }
       return result;
    }

}
